﻿Namespace Tools
    Public Class clsByteReaderFunctions
        Public Shared Function GetDataPart(ByVal data() As Byte, ByVal offset As Integer, ByVal length As Integer) As Byte()
            Dim out(length - 1) As Byte

            For i = 0 To length - 1
                out(i) = data(offset + i)
            Next

            Return out
        End Function
        Public Shared Function GetDataPartToInteger(ByVal data() As Byte, ByVal offset As Integer, ByVal length As Integer) As Integer
            Dim iOut As Integer = 0
            Dim bytes() As Byte = GetDataPart(data, offset, length)

            For i = bytes.Count - 1 To 0 Step -1
                iOut += bytes(i) * Math.Pow(&H100, i)
            Next

            Return iOut
        End Function
        Public Shared Function GetDataPartToString(ByVal data() As Byte, ByVal offset As Integer, ByVal length As Integer) As String
            Return System.Text.Encoding.Unicode.GetString(GetDataPart(data, offset, length))
        End Function
    End Class
End Namespace
